package com.ruoyi.shopUserRelation.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.shopUserRelation.domain.UserShopRelation;
import com.ruoyi.shopUserRelation.service.IUserShopRelationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户门店关联信息Controller
 * 
 * @author ruoyi
 * @date 2025-11-18
 */
@RestController
@RequestMapping("/ruoyi/userShopRelation")
public class UserShopRelationController extends BaseController
{
    @Autowired
    private IUserShopRelationService userShopRelationService;

    /**
     * 查询用户门店关联信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserShopRelation userShopRelation)
    {
        startPage();
        List<UserShopRelation> list = userShopRelationService.selectUserShopRelationList(userShopRelation);
        return getDataTable(list);
    }

    /**
     * 导出用户门店关联信息列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:export')")
    @Log(title = "用户门店关联信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserShopRelation userShopRelation)
    {
        List<UserShopRelation> list = userShopRelationService.selectUserShopRelationList(userShopRelation);
        ExcelUtil<UserShopRelation> util = new ExcelUtil<UserShopRelation>(UserShopRelation.class);
        util.exportExcel(response, list, "用户门店关联信息数据");
    }

    /**
     * 获取用户门店关联信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:query')")
    @GetMapping(value = "/{relationId}")
    public AjaxResult getInfo(@PathVariable("relationId") Long relationId)
    {
        return success(userShopRelationService.selectUserShopRelationByRelationId(relationId));
    }

    /**
     * 新增用户门店关联信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:add')")
    @Log(title = "用户门店关联信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserShopRelation userShopRelation)
    {
        return toAjax(userShopRelationService.insertUserShopRelation(userShopRelation));
    }

    /**
     * 修改用户门店关联信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:edit')")
    @Log(title = "用户门店关联信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserShopRelation userShopRelation)
    {
        return toAjax(userShopRelationService.updateUserShopRelation(userShopRelation));
    }

    /**
     * 删除用户门店关联信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi:userShopRelation:remove')")
    @Log(title = "用户门店关联信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{relationIds}")
    public AjaxResult remove(@PathVariable Long[] relationIds)
    {
        return toAjax(userShopRelationService.deleteUserShopRelationByRelationIds(relationIds));
    }
}
